Learn R Programming

ncdfCF (version 0.4.0)

[[.CFDataset: Get a variable or axis object from a data set

Description

This method can be used to retrieve a variable or axis from the data set by name.

Usage

# S3 method for CFDataset
[[(x, i)

Value

An instance of CFVariable or an CFAxis descendant class, or NULL if the name is not found.

Arguments

x

An CFDataset to extract a variable or axis from.

i

The name of a variable or axis in x. If data set x has groups, i should be an absolute path to the object to retrieve.

Details

If the data set has groups, the name i of the variable or axis should be fully qualified with the path to the group where the object is located. This fully qualified name can be retrieved with the names() and dimnames() functions, respectively.

Examples

Run this code
fn <- system.file("extdata", "ERA5land_Rwanda_20160101.nc", package = "ncdfCF")
ds <- open_ncdf(fn)
v1 <- names(ds)[1]
var <- ds[[v1]]
var

Run the code above in your browser using DataLab